-- 浮动窗口
function floatingWindow()
    fwShowWnd("window1", 500, 0, 500 + 50 * 2, 30, 1);
    -- 子窗口视图是以父窗口载体的（100,100）点坐标为（0,0）点坐标显示的  
    fwShowButton("window1", "btn1", "on", "FFFFFF", "025062", "", 12, 0, 0, 50, 30);
    fwShowButton("window1", "more", "...", "FFFFFF", "306090", "", 12, 51, 0, 50 * 2, 30);
    mSleep(500)
end
-- 多功能窗口
function moreWindow()
    var.isLuaStart = 0
    fwShowWnd("moreWin", 100, 100, wScreen - 100, hScreen - 100, 0);
    -- 子窗口视图是以父窗口载体的（100,100）点坐标为（0,0）点坐标显示的  
    fwShowButton("moreWin", "btn_update", "更新", "FFFFFF", "025062", "", 12, 0, 0, 150, 50);
    local tmpXuanXiang = string.find(var.zongHeXuanXiang1, "3")
    if tmpXuanXiang ~= nil then
        fwShowButton("moreWin", "btn_tiaoShi", "调试ON", "FFFFFF", "306090", "", 12, 1 + 150, 0, 150 * 2, 50);
    else
        fwShowButton("moreWin", "btn_tiaoShi", "调试OFF", "FFFFFF", "306090", "", 12, 1 + 150, 0, 150 * 2, 50);
    end
    fwShowButton("moreWin", "btn_snapshot", "截图", "FFFFFF", "025062", "", 12, 1 + 150 * 2, 0, 150 * 3, 50);
    fwShowTextView("moreWin", "text_MuBiao",
        "目标1 : " .. var.muBiao1 .. "  目标2 : " .. var.muBiao2 .. "  目标3 : " .. var.muBiao3, "left", "FFFFFF", "0C2037",
        12, 0, 0, 51, wScreen - 200, 100, 1);

    mSleep(500)
end
-- 窗口判断
function windowsDecide()
    vid, kind = fwGetPressedButton();
    if vid == "btn1" then
        fwCloseView("window1", "btn1"); -- 关闭文字视图
        fwShowButton("window1", "btn2", "off", "FFFFFF", "8a4c17", "", 12, 0, 0, 50, 30);
        mSleep(500)
        repeat
            mSleep(1000)
            vid, kind = fwGetPressedButton();
            if vid == "btn2" then
                fwCloseView("window1", "btn2"); -- 关闭文字视图
                fwShowButton("window1", "btn1", "on", "FFFFFF", "025062", "", 12, 0, 0, 50, 30);
                mSleep(500)
            elseif  vid == "more" then
                isLuaStart = false
                fwCloseView("window1", "btn1"); -- 关闭文字视图
                fwShowButton("window1", "btn2", "off", "FFFFFF", "8a4c17", "", 12, 0, 0, 50, 30);
                fwCloseView("window1", "more"); -- 关闭文字视图
                fwShowButton("window1", "moreX", "X", "FFFFFF", "9e393d", "", 12, 51, 0, 50 * 2, 30);
                mSleep(500)
                moreWindow()
            end
        until vid == "btn2" or vid == "more"
        var.isLuaStart = 0
    elseif vid == "btn2" then
        fwCloseView("window1", "btn2"); -- 关闭文字视图
        fwShowButton("window1", "btn1", "on", "FFFFFF", "025062", "", 12, 0, 0, 50, 30);
        mSleep(500)
        var.isLuaStart = 1
    elseif vid == "more" then
        var.isLuaStart = 0
        fwCloseView("window1", "btn1"); -- 关闭文字视图
        fwShowButton("window1", "btn2", "off", "FFFFFF", "8a4c17", "", 12, 0, 0, 50, 30);
        fwCloseView("window1", "more"); -- 关闭文字视图
        fwShowButton("window1", "moreX", "X", "FFFFFF", "9e393d", "", 12, 51, 0, 50 * 2, 30);
        mSleep(500)
        moreWindow()
    elseif vid == "moreX" then
        var.isLuaStart = 1
        fwCloseView("window1", "btn2"); -- 关闭文字视图
        fwShowButton("window1", "btn1", "on", "FFFFFF", "025062", "", 12, 0, 0, 50, 30);
        fwCloseView("window1", "moreX"); -- 关闭文字视图
        fwShowButton("window1", "more", "...", "FFFFFF", "306090", "", 12, 51, 0, 50 * 2, 30);
        mSleep(500)
        fwCloseWnd("moreWin"); -- 关闭父窗口
    elseif vid == "btn_update" then
        closeFw()
        onlineLua()
        var.isRoundUI = 0
        var.isRound = 0

    elseif vid == "btn_tiaoShi" then
        local tmpXuanXiang = string.find(var.zongHeXuanXiang1, "3")
        if tmpXuanXiang ~= nil then
            var.zongHeXuanXiang1, num = string.gsub(var.zongHeXuanXiang1, "3", "c")
            fwShowButton("moreWin", "btn_tiaoShi", "调试OFF", "FFFFFF", "306090", "", 12, 1 + 150, 0, 150 * 2, 50);
        else
            var.zongHeXuanXiang1, num = string.gsub(var.zongHeXuanXiang1, "c", "3")
            fwShowButton("moreWin", "btn_tiaoShi", "调试ON", "FFFFFF", "306090", "", 12, 1 + 150, 0, 150 * 2, 50);
        end
    elseif vid == "btn_snapshot" then
        fwCloseWnd("moreWin"); -- 关闭父窗口
        current_time = os.date("%m-%d_%H.%M", os.time());
        -- snapshot(
        --     "/private/var/mobile/Library/Mobile%20Documents/com~apple~CloudDocs/" .. iphoneId ..
        --         ".png", 0, 0, 1135, 639); -- 以时间戳命名进行截图
        snapshot(var.iphoneId .. "-" .. current_time .. ".png", 0, 0, 1135, 639,1); -- 以时间戳命名进行截图
        ftpUpPNG(var.iphoneId .. "-" .. current_time .. ".png", "PNG/")
        mSleep(2000)
        delFile(userPath() .. "/res/" .. var.iphoneId .. "-" .. current_time .. ".png")
        moreWindow()
    end
end

floatingWindow()
while var.isRoundUI == 1 do
    windowsDecide()
end
var.isRoundUI =2